/*
 * Copyright:  2018 smarabbit studio.
 *
 *  Licensed under the Confluent Community License; you may not use this file
 *  except in compliance with the License.  You may obtain a copy of the License at
 *
 *  http://www.confluent.io/confluent-community-license
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 *  WARRANTIES OF ANY KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations under the License.
 *
 *  @作   者： 黄开晖 (117227773@qq.com)
 *  @日   期:  2020年8月22日
 */
package com.massyframework.beanskin.service;

import java.util.Collection;
import java.util.Map;

import com.massyframework.beanskin.util.version.Version;

/**
 * 输出服务定义构建器
 * 
 * @author huangkh
 *
 */
public interface ExportServiceDescriptorBuilder {

	 /**
     * 添加输出的服务类型
     * @param exportType {@link Class}
     * @return {@link ExportServiceDescriptorBuilder}
     */
    ExportServiceDescriptorBuilder addExportService(Class<?> exportType);
    
    /**
     * 添加输出的服务类型
     * @param exportTypes {@link Collection}
     * @return {@link ExportServiceDescriptorBuilder} 
     */
    ExportServiceDescriptorBuilder addExportServices(Collection<Class<?>> exportTypes);
    
    /**
     * 添加输出的服务类型
     * @param exportTypes {@link Collection}
     * @return {@link ExportServiceDescriptorBuilder} 
     */
    ExportServiceDescriptorBuilder addExportServices(Class<?>[] exportTypes);
    
    /**
     * 设置输出的Bean名称
     * @param value {@link String}
     * @return {@link ExportServiceDescriptorBuilder}
     */
    ExportServiceDescriptorBuilder beanName(String value);

    /**
     * 设置服务名称
     * @param value {@link String}
     * @return {@link ExportServiceDescriptorBuilder}
     */
    default ExportServiceDescriptorBuilder name(String value){
        return this.property(ServiceReference.SERVICE_NAME, value);
    }

    /**
     * 设置服务说明
     * @param value {@link String}
     * @return {@link ExportServiceDescriptorBuilder}
     */
    default ExportServiceDescriptorBuilder description(String value){
        return this.property(ServiceReference.SERVICE_DESCRIPTION, value);
    }

    /**
     * 设置注册对象是否是ServiceFactory实例
     * @param value {@link boolean}
     * @return {@link ExportServiceDescriptorBuilder}
     */
    default ExportServiceDescriptorBuilder isFactory(boolean value){
        return this.property(ServiceReference.SERVICE_ISFACTORY, value);
    }

    /**
     * 设置服务版本
     * @param value {@link Version}
     * @return {@link ExportServiceDescriptorBuilder}
     */
    default ExportServiceDescriptorBuilder version(Version value){
        if (value != null) {
           this.property(ServiceReference.SERVICE_VERSION, value);
        }
        return this;
    }

    /**
     * 设置服务排名为最大
     * @return {@link ExportServiceDescriptorBuilder}
     */
    default ExportServiceDescriptorBuilder topRanking(){
        return this.property(ServiceReference.SERVICE_RANKING, Integer.MAX_VALUE);
    }

    /**
     * 添加属性
     * @param name {@link String}, 属性名
     * @param value {@link Object}, 属性值
     * @return {@link ExportServiceDescriptorBuilder}
     */
    ExportServiceDescriptorBuilder property(String name, Object value);
    
    /**
     * 添加属性集
     * @param props {@link Map}
     * @return {@link ExportServiceDescriptor}
     */
    ExportServiceDescriptorBuilder properties(Map<String, Object> props);
    
    /**
     * 创建输出服务描述
     * @return {@link ExportServiceDescriptor}
     */
    ExportServiceDescriptor build();
    
}
